package com.hrrt.home.admin.controller.manage;

import com.hrrt.common.base.BaseController;
import com.hrrt.home.common.constant.HomeResult;
import com.hrrt.home.common.constant.HomeResultConstant;
import com.hrrt.home.socket.utils.SocketUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

/**
 * 家电品牌controller
 * Created by JiangXueLi on 2017/08/24.
 */
@Controller
@RequestMapping("/manage/socket")
@Api(value = "连接管理", description = "连接管理")
public class HomeSocketController extends BaseController {
    @ApiOperation(value = "打开连接")
    @RequiresPermissions("home:socket:read")
    @RequestMapping(value = "/start", method = RequestMethod.GET)
    @ResponseBody
    public Object start() {
        try {
            SocketUtil.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new HomeResult(HomeResultConstant.SUCCESS, 1);

    }

}
